<template>
  <div class="pages">
    <div>
      共<span>{{ Length }}</span
      >条
    </div>
    <div class="pageNum">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="Length"
        @current-change="setSize($event)"
      />
    </div>
    <div class="rows">
      <select @change="setPages($event.target.value)">
        <option value="10">10条/页</option>
        <option value="20">20条/页</option>
        <option value="30">30条/页</option>
        <option value="40">40条/页</option>
        <option value="50">50条/页</option>
      </select>
    </div>
    <div class="toPage">
      <div>
        到第
        <input type="text" v-model="val" @blur="setVal(val)" /> 页
      </div>
    </div>
    <div class="confirm" @click="setPage">确定</div>
  </div>
</template>

<script setup>
import { ref, computed, onMounted } from "vue";
import { tableLength } from "../../../utils/api/f_request";
const props = defineProps(["pageLeng"]);
const Length = ref("");
const emit = defineEmits(["changeT", "changeTs"]);
//控制页码颜色
const setatPage = ref(false);
//获取input
const setVal = (v) => {
  val = v;
};
//第几页
let val = 1;
//到第几页
const setPage = () => {
  emit("changeT", val);
};
//页码控制显示数据
const setSize = (v) => {
  emit("changeT", v);
};
//选择一页多少条
const setPages = (val) => {
  emit("changeTs", val);
};
//设置初始条数
onMounted(() => {
  tableLengths();
});
const tableLengths = () => {
  tableLength().then((data) => {
    Length.value = data.data.data.length;
  });
};
</script>

<style lang="scss">
.pages {
  display: flex;
  flex-direction: row;
  align-items: center;
  height: 80px;
  width: 100%;
  justify-content: end;
  .rows {
    margin-left: 1%;
    select {
      height: 35px;
      width: 75px;
    }
  }
  .toPage {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-left: 1%;
    input {
      height: 30px;
      width: 50px;
      text-align: center;
    }
  }
  .confirm {
    margin-left: 1%;
    text-align: center;
    border: none;
    border: 1px solid #e6f1ff;
    height: 32px;
    line-height: 32px;
    width: 55px;
    background-color: #ffffff;
    color: #006eff;
    margin-right: 2%;
    cursor: pointer;
  }
  .confirm:hover {
    background-color: #006eff;
    color: #ffffff;
  }
}
</style>